package com.example.juyixia;


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.example.adapter.ActiveAdapter;
import com.exanple.data.Activeinfo;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageView;
import android.widget.ListView;

public class MyActiveActivity extends Activity implements OnClickListener{
	private ImageView mIv_Back;
	public static final String bm="utf-8";
	private ListView activeList;
	private Myinfo myinfo;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		myinfo=(Myinfo)getApplication();
		requestWindowFeature(Window.FEATURE_NO_TITLE);  
        setContentView(R.layout.activity_myactive);  
        activeList = (ListView)findViewById(R.id.myactivelist);    
        List<Activeinfo> list=Activeinfo.activelist;
        //适配器，刚刚重写的！
        ActiveAdapter  myactiveAdapter = new ActiveAdapter(this, list);
        //设置适配器
        activeList.setAdapter(myactiveAdapter);
//        activeList.setOnClickListener(new OnClickListener() {
//			
//			@Override
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				Intent intent=new Intent(getApplicationContext(), Map_Activity.class);;
//				startActivity(intent);
//			}
//		});
        activeList.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(getApplicationContext(), Map_Activity.class);
				//从我的位置进入地图
				String message = "活动";
				intent.putExtra("message",message);
				//判断用户
				String uid = myinfo.getUserid();
				intent.putExtra("id", uid);
				startActivity(intent);
			}
		});
        initViews();
	}
	public List<Map<String, Object>> getData() {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        	Map<String, Object> map = new HashMap<String, Object>();
        	map.put("activename","聚会");
        	map.put("parter", "参与者：李豪，尚甲");
        	map.put("activetime","2017.6.7");
        	 list.add(map);
		
       
        return list;
    }
	private void initViews() {
		// TODO Auto-generated method stub
		mIv_Back = (ImageView) findViewById(R.id.iv_back);
		mIv_Back.setOnClickListener(this);
	}
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		
		switch (v.getId()) {
		case R.id.iv_back:
			finish();
			break;
		default:
			break;
		}
	}

	
	
	
}
